package com.example.demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jiangwz
 * @create 2019/11/4.
 */
@RestController
@RequestMapping("/redisson")
public class RedissonTestController {


//    @Autowired
//    RedissonLock redissonLock;
//
//    @GetMapping("/")
//    public Object testRedissonLock(){
//        String lockName = "test:testRedissonLock";
//        redissonLock.lock(lockName, 20);
//        System.out.println("testRedissonLock lock...");
//        try { TimeUnit.SECONDS.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); }
//        System.out.println("testRedissonLock unlock...");
//        redissonLock.unlock(lockName);
//        return Result.ok();
//    }
//
//    @GetMapping("/a")
//    @DistributedLock(value = "test:testRedissonLock", leaseTime = 20)
//    public Object testRedissonLockAnnotation(){
//        try { TimeUnit.SECONDS.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); }
//        return Result.ok();
//    }
}
